package PTA_JAVA.JavaB.Javademo26;

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        ArrayList<Date> arr = new ArrayList();
        SimpleDateFormat d=new SimpleDateFormat("yyyy-MM-dd");
        int f=0;
        for (int i = 0; i < n; i++) {
            String s= sc.next();
            try{
                arr.add(d.parse(s));
            }catch (Exception e){
                System.out.println("Line "+i+" error. "+e.getMessage());
                f++;
            }
        }
        System.out.println("Totally "+f+" lines error.");
        d=new SimpleDateFormat("MM dd, yyyy");
        Collections.sort(arr);
        for(Date i:arr){
            System.out.println(d.format(i));
        }
    }
}
